package com.dyna.digit.process.dao;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dyna.digit.process.domain.entity.DigitProject;
import com.dyna.digit.process.mapper.DigitProjectMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhoucaiwang
 * @date 2023/12/24
 */

@Service
public class DigitProjectDao extends ServiceImpl<DigitProjectMapper, DigitProject> {

    /**
     * 删除项目申报主表信息
     * @param projectId 项目id
     * @return int
     */
    public Boolean del(Integer projectId) {
        return removeById(projectId);
    }

    /**
     * 批量删除项目主表信息
     * @param projectIds 项目ids
     * @return Boolean
     */
    public Boolean batchDel(List<Integer> projectIds) {
        LambdaUpdateWrapper<DigitProject> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.in(CollUtil.isNotEmpty(projectIds), DigitProject::getProjectId, projectIds);
        return update(updateWrapper);
    }

    public Boolean delProject(Integer projectId) {
        LambdaUpdateWrapper<DigitProject> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(DigitProject::getProjectId, projectId);
        return update(updateWrapper);
    }

}
